﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using BLL;

public partial class manager_add : System.Web.UI.Page
{

    BLL.Business.ManagerBLL managerBLL = new BLL.Business.ManagerBLL();
    Model.Manager manager =  new Model.Manager ();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
        }
    }
    // 管理员添加

    protected void Button1_Click(object sender, EventArgs e)
    {
        try
        {
            String name = this.name.Text.Trim().ToString();
            String password = this.password.Text.Trim().ToString();

            if (!managerBLL.IsExist(name))  // 此用户名不存在
            {
                manager.Manager_Namestr = name;
                manager.Manager_Passwordstr = password;
                if (managerBLL.InsertManager(manager))
                    Response.Write("<script>alter('添加成功!')</script>");
                else
                    Response.Write("<script>alter('添加失败!')</script>");
            }
            else
            {
                Response.Write("<script>alter('该用户已存在!')</script>");
            }
        }
        catch (Exception ex)
        {
            Response.Write("<script>alert('" + ex.Message.ToString() + "')</script>");
        }
    }
}
